package com.thexb.sys.mapper;

import com.thexb.sys.entity.Menu;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * <p>
 *  Mapper 接口
 * </p>
 *
 * @author thexb
 * @since 2023-04-04
 */
public interface MenuMapper extends BaseMapper<Menu> {
    @Select("select DISTINCT * FROM\n" +
        "x_menu, x_role_menu, x_user_role\n" +
        "where x_user_role.role_id = x_role_menu.role_id\n" +
        "and x_role_menu.menu_id = x_menu.menu_id\n" +
        "and x_user_role.user_id = #{user_id}\n" +
        "and x_menu.parent_id = #{parent_id}\n")
    List<Menu> getLoginMenu(@Param("user_id") int user_id, @Param("parent_id") int parent_id);
}
